home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / gs3.53 / prfont.ps < prev    next >
Text File  |  1996-01-10  |  4KB  |  150 lines

  1. %!
  2. %%Creator: Eric Gisin <egisin@waterloo.csnet>
  3. %%Title: Print font catalog
  4. % Copyright (c) 1986 Eric Gisin
  5. % Copyright (C) 1992 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  6. %   Modified to print all 256 encoded characters.
  7. % Copyright (C) 1993 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  8. %   Modified to print unencoded characters.
  9. % Copyright (C) 1994 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  10. %   Modified to always create 256-element Encoding vectors.
  11. % Copyright (C) 1995 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  12. %   Modified to print more than 128 unencoded characters.
  13.  
  14. % Example usages at bottom of file
  15.  
  16. /#copies 1 def
  17. /min { 2 copy gt { exch } if pop } bind def
  18.  
  19. /T6 /Times-Roman findfont 6 scalefont def
  20. /Temp 64 string def
  21. /Inch {72 mul} def
  22. /Base 16 def    % char code output base
  23. /TempEncoding [ 256 { /.notdef } repeat ] def
  24.  
  25. % do single character of page
  26. % output to rectangle ll=(0,-24) ur=(36,24)
  27. /DoChar {
  28.   /C exch def
  29.   /S (_) dup 0 C put def
  30.   /N F /Encoding get C get def
  31.  
  32.   % print code name, width and char name
  33.   /W F setfont S stringwidth pop def
  34.   T6 setfont
  35.   N /.notdef ne {0 -20 moveto N Temp cvs show} if
  36.   0 -12 moveto C Base Temp cvrs show (  ) show
  37.   W 0.0005 add Temp cvs 0 5 getinterval show
  38.  
  39.   % print char with reference lines
  40.   N /.notdef ne {
  41.     3 0 translate
  42.     0 0 moveto F24 setfont N glyphshow
  43.     /W S stringwidth pop def
  44.     0 -6 moveto 0 24 lineto
  45.     W -6 moveto W 24 lineto
  46.     -3 0 moveto W 3 add 0 lineto
  47.     0 setlinewidth stroke
  48.   } if
  49. } def
  50.  
  51. % print page title
  52. /DoTitle {
  53.   /Times-Roman findfont 18 scalefont setfont
  54.   18 10.5 Inch moveto FName Temp cvs show ( ) show ((24 point)) show
  55. } def
  56.  
  57. % print one block of characters
  58. /DoBlock {    % firstcode lastcode
  59.   /FirstCode 2 index def
  60.   1 exch {
  61.     /I exch def
  62.     /Xn I FirstCode sub 16 mod def /Yn I FirstCode sub 16 idiv def
  63.     gsave
  64.     Xn 36 mul 9 add Yn -56 mul 9.5 Inch add translate
  65.     I DoChar
  66.     grestore
  67.   } for
  68. } def
  69.  
  70. % print a line of character
  71. /DoLine {    % firstcode lastcode
  72.   1 exch { (_) dup 0 3 index put show pop } for
  73. } def
  74.  
  75. % print font sample page
  76. /DoFont {
  77.   /FName exch def    % font name
  78.   /F FName findfont def
  79.   /F24 F 24 scalefont def
  80.   /Line0 96 string def
  81.   /Line1 96 string def
  82.  
  83.     % Display the first 128 encoded characters.
  84.  
  85.   DoTitle (, characters 0-127) show
  86.   0 127 DoBlock
  87.   F 10 scalefont setfont
  88.   18 2.0 Inch moveto 0 63 DoLine
  89.   18 1.5 Inch moveto 64 127 DoLine
  90.   showpage
  91.  
  92.     % Display the second 128 encoded characters.
  93.  
  94.   DoTitle (, characters 128-255) show
  95.   128 255 DoBlock
  96.   F 10 scalefont setfont
  97.   18 2.0 Inch moveto 128 191 DoLine
  98.   18 1.5 Inch moveto 192 255 DoLine
  99.   showpage
  100.  
  101.   F /FontType get 1 eq
  102.    {
  103.         % Find and display the unencoded characters.
  104.  
  105.     /Encoded F /Encoding get length dict def
  106.     F /Encoding get { true Encoded 3 1 roll put } forall
  107.     /Unencoded [ F /CharStrings get
  108.      { pop dup Encoded exch known { pop } if }
  109.     forall ] def
  110.     /Count Unencoded length def
  111.  
  112.         % Print the unencoded characters in blocks of 128.
  113.  
  114.     0 128 Unencoded length 1 sub
  115.      { dup 128 add Unencoded length min 1 index sub
  116.        Unencoded 3 1 roll getinterval TempEncoding copy
  117.        /BlockEncoding exch def
  118.        /BlockCount BlockEncoding length def
  119.        save
  120.        F length dict F
  121.         { 1 index /FID eq { pop pop } { 2 index 3 1 roll put } ifelse }
  122.        forall dup /Encoding TempEncoding put
  123.        /* exch definefont
  124.        /F exch def
  125.        /F24 F 24 scalefont def
  126.  
  127.        DoTitle (, unencoded characters) show
  128.        0 BlockCount 1 sub DoBlock
  129.        F 10 scalefont setfont
  130.        18 2.0 Inch moveto 0 BlockCount 64 min 1 sub DoLine
  131.        BlockCount 64 gt
  132.         { 18 1.5 Inch moveto 64 BlockCount 128 min 1 sub DoLine
  133.         }
  134.        if
  135.        showpage
  136.        restore
  137.      } for
  138.  
  139.    }
  140.   if
  141.  
  142. } def
  143.  
  144. % Do font samples
  145. % /Times-Roman DoFont            % Test (less than a minute)
  146. % /Hershey-Gothic-English DoFont    % Test (8 minutes)
  147.  
  148. % Do a complete catalog
  149. % FontDirectory {pop DoFont} forall    % All fonts (quite a long time)
  150.